python3 iterate through indexes

47

python3 iterate through indexes -

items=['baseball','basketball','football']
for index, item in enumerate(items):
    print(index, item)

for loop with index python3 -

colors = ["red", "green", "blue", "purple"]

for i in range(len(colors)):
    print(colors[i])

Comments

Submit
0 Comments